package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> queryShoppingCart(Long userId);

    @Insert("insert into shopping_cart(dish_id, setmeal_id, dish_flavor, user_id, name, image, number, amount, create_time)\n" +
            " values (#{dishId}, #{setmealId}, #{dishFlavor}, #{userId}, #{name}, #{image}, #{number}, #{amount}, #{createTime})")
        // @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(ShoppingCart shoppingCart);

    void update(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where id = #{id}")
    void delShoppingCart(Long id);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void delByUserId(Long userId);

    List<ShoppingCart> list(ShoppingCart shoppingCart);

}
